capture log close
log using suic-econ-a5-unemp.txt, replace text

//  program:    suic-econ-a5-unemp.do
//  task:		estimate impact of unemployment on suicide: poisson models
// 	input:		suic-econ-data1-census.dta
//	output:		suic-econ-stable-unemp.txt
//  project:    economic conditions and suicide
//  author:     sam harper \ 17dec2014

//  #0
//  program setup

version 12
set linesize 80
clear all
macro drop _all
set matsize 11000


// #1
// data and descriptive table

use suic-econ-data1-census.dta, clear



// #2
// crude poisson model without adjustments: Model 0

poisson suic unemprtsa, offset(logpop100y) vce(cluster stabb) nolog irr

* predicted marginal effects
eststo m_0: estpost margins, at(unemprtsa=(5.8 9.6)) predict(ir) ///
	contrast(atcontrast(r._at)) vce(unconditional) cformat(%4.2f)


	
	
// #3
// now add individual covariates: Model 1

poisson suic unemprtsa i.sex i.race2 i.agecat, offset(logpop100y) ///
	vce(cluster stabb) nolog irr cformat(%4.3f)

* predicted margins
eststo m_1: estpost margins, at(unemprtsa=(5.8 9.6)) predict(ir) ///
	contrast(atcontrast(r._at)) vce(unconditional) cformat(%4.2f)

	

// #4
// now add state and quarter fixed effects: Model 2

poisson suic unemprtsa i.sex i.race2 i.agecat i.stabb i.season##i.year, ///
	offset(logpop100y) vce(cluster stabb) nolog irr cformat(%4.3f)

* predicted marginal effects
eststo m_2: estpost margins, at(unemprtsa=(5.8 9.6)) predict(ir) ///
	contrast(atcontrast(r._at)) vce(unconditional) cformat(%4.2f)
	



// #5
// now add state-specific trends to FE model: Model 3

poisson suic unemprtsa i.sex i.race2 i.agecat i.stabb##c.quarter ///
	i.season##i.year, offset(logpop100y) vce(cluster stabb) nolog ///
	irr cformat(%4.3f)

* predicted marginal effects
eststo m_3: estpost margins, at(unemprtsa=(5.8 9.6)) predict(ir) ///
	contrast(atcontrast(r._at)) vce(unconditional) cformat(%4.2f) 

	
	

// #6
// now add state-specific quadratic time trends to basic FE model: Model 4

poisson suic unemprtsa i.sex i.race2 i.agecat ///
	i.stabb##(c.quarter##c.quarter) i.season##i.year, ///
	offset(logpop100y) vce(cluster stabb) nolog irr cformat(%4.3f)

* predicted margins
eststo m_4: estpost margins, at(unemprtsa=(5.8 9.6)) predict(ir) ///
	contrast(atcontrast(r._at)) vce(unconditional) cformat(%4.2f)

	
	

// #7 	
// include state-specific cubic trends: Model 5

poisson suic unemprtsa i.sex i.race2 i.agecat ///
	i.stabb##(c.quarter##c.quarter##c.quarter) ///
	i.season##i.year, offset(logpop100y) vce(cluster stabb) nolog ///
	irr cformat(%4.3f)

* predicted margins
eststo m_5: estpost margins, at(unemprtsa=(5.8 9.6)) predict(ir) ///
	contrast(atcontrast(r._at)) vce(unconditional) cformat(%4.2f)
	
	
	

// #8
// write results to file

esttab m_* using suic-econ-atable-unemp.txt,  ///
	cells("b(fmt(%4.2f)) ci(par( ( , ) ))") collabels(Est. 95%CI) nostar ///
	wide not delimiter(";") replace
	

log close
exit	
